package com.sh.ndt.user.mapper;

import com.sh.ndt.common.mapper.BaseRowMapper;
import com.sh.ndt.user.entity.User;
import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * Mapper class used to map User data returned by sp_Login
 *
 * @author Manjula Hosadurga
 */
public class UserMapper extends BaseRowMapper {

    @Override
    public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
        User user = null;
        try {
            user = new User();
            user.setUserId(rs.getInt("USER_ID"));
            user.setFirstName(rs.getString("FRIST_NAME"));
            user.setLastName(rs.getString("LAST_NAME"));
            user.setPrimaryEmail(rs.getString("PRIMARY_EMAIL"));
            user.setAddress1(rs.getString("ADDRESS1"));
            user.setAddress2(rs.getString("ADDRESS2"));
            user.setCity(rs.getString("CITY"));
            user.setState(rs.getString("STATE"));
            user.setZip(rs.getString("ZIP"));
            user.setCountry(rs.getString("COUNTRY"));
            user.setCellPhoneNumber(rs.getString("CELL_PHONENUMBER"));
            user.setOfficePhoneNumber(rs.getString("OFFICE_PHONENUMBER"));
            user.setSecondaryEmail(rs.getString("SECONDARY_EMAIL"));
            //user.setPassword(rs.getString("PASSWORD"));
            //user.setConfirmPassword(rs.getString("CONFIRM_PASSWORD"));
            user.setWebSiteAddress(rs.getString("WEBSITE_ADDRESS"));
            user.setBlogAddress(rs.getString("BLOG_ADDRESS"));
            user.setLoginCount(rs.getLong("LOGIN_COUNT"));
            user.setRoleId(rs.getInt("USER_ROLE"));
            user.setUserType(rs.getInt("USER_TYPE"));
            //user.setCreatedBy(rs.getString("CREATED_BY"));
            //user.setCratedDate(rs.getDate("CREATED_DATE"));
            //user.setUpdatedBy(rs.getString("LAST_MODIFIED_BY"));
            //user.setUpdatedDate(rs.getDate("LAST_MODIFIED_DATE"));

        } catch (SQLException e) {
            throw e;
        }

        return user;
    }
}
